package com.shopcart.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

@Entity
@Table(name = "SHOP_CARTITEM")
public class CartItem implements java.io.Serializable {

	private static final long serialVersionUID = -7067897334200799055L;

	@TableGenerator(name = "itemIdGen", table = "SHOP_SEQUENCE_GENERATOR", pkColumnName = "GEN_KEY", valueColumnName = "GEN_VALUE", pkColumnValue = "ITEM_ID", initialValue = 1, allocationSize = 1)
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "itemIdGen")
	@Column(name = "ITEM_ID", nullable = false)
	private Long id;

	@ManyToOne
	@JoinColumn(name = "PRODUCT_ID")
	private Product product;

	@Column(name = "COUNT")
	private Integer count;

	public CartItem() {
	}

	public CartItem(Long id, Product product, Integer count) {
		this.setId(id);
		this.setProduct(product);
		this.setCount(count);
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}
}